package listen

import (
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/columnd"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/infod"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/interactiond"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/ddd"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/evt/userclievt"
)

// Init 初始化事件监听
func Init(d ddd.Domain) {
	l := &listener{
		iiar: d.SubDomain(interactiond.DomainID).AggregateRootByID(interactiond.Interaction).(interactiond.InteractionAggregateRoot),
		irar: d.SubDomain(interactiond.DomainID).AggregateRootByID(interactiond.Replay).(interactiond.ReplayAggregateRoot),
		igar: d.SubDomain(interactiond.DomainID).AggregateRootByID(interactiond.Group).(interactiond.GroupAggregateRoot),
		iar:  d.SubDomain(infod.DomainID).AggregateRootByID(infod.DomainID).(infod.InfoAggregateRoot),
		car:  d.SubDomain(columnd.DomainID).AggregateRootByID(columnd.DomainID).(columnd.ColumnAggregateRoot),
	}
	// 监听浏览信息详细页面事件,增加浏览记数
	userclievt.AddEventListenerForLookInfoEvent(l.InfoCountAddOne)

	// 监听评论对接外部推送
	interactiond.AddListenerForReply(l.Reply)
}
